<%--
 *  File:    UMCodeSummary.jsp
 *  @Author: Kent Zhong 
 *  Date:    2002/05/08
 *
 *  Copyright (C) 2000 - 2002 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
 

<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page import="com.oval.util.*" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom-tag.tld" prefix="custom" %>


<% //--------------------------------------  setting logger --%>
<%
  	Category cat = Category.getInstance("jsp.UMCodeSummary");  
%>

<% //--------------------------------------  variant and initialization --%>
<%
	String strModuleName = "IMG";
  	String strTableName = "ovumcode";
	String privilegeCode = "Z0804";
  	
  	//get current userinfo
  	HashMap CurUserInfo = (HashMap)session.getAttribute("userinfo");
  	cat.debug("The userinfo is :"+CurUserInfo);
  	cat.info("enter my page");
%>

<% //--------------------------------------  include files list --%>

<%@ include file="/inc/Security.inc" %>

<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>

<html>
<head>
<title>UMCodeSummary</title>
<PageFlow:CheckPageFlow pageName="umcodesummary"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="../css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="../js/FuncLib.js"></script>
<%@ include file="/inc/SummaryDivision.inc" %>
<script language="JavaScript" >

    function page_summary(actionvalue,orderbyname)
	{
	  var editform = summaryPrepare(umcodesummaryform,actionvalue,orderbyname);
	  editform.action = "UMCodeSummary.jsp?<%= OvalTools.randomURL() %>";
	  editform.target = "_self";
	  isRunning = true;
	  editform.submit();  
	}
	
    function page_radiotrue(selid,selcode)
    {
        radiotrue(selid);
        var selobj = eval("document.umcodesummaryform." + selid);
        document.umcodesummaryform.selectedid.value=selobj.value;
        document.umcodesummaryform.selectedcode.value=selcode;
        document.umcodesummaryform.umcode.value=selcode;
        parent.down.location.href="Blank.jsp?<%= OvalTools.randomURL() %>";
    }
    function page_edit()
    {
        <%--[SCRIPT]  alert("OK");  [SCRIPT]--%>
        var id = document.umcodesummaryform.selectedid.value;
        if(id == null || id.length == 0 || id == "" || id == "-1")
        {
            alert("<%= message.getMessageDesc("PLEASE_SELECT") %>");
            return;
        }  
        var strCode=document.umcodesummaryform.selectedcode.value;
        var strid=document.umcodesummaryform.selectedid.value;
        parent.down.location.href="UmCodeEdit.jsp?<%= OvalTools.randomURL() %>&umcode="+strCode+"&umid="+strid;
    }
    
    function page_delete()
    {
          var id = document.umcodesummaryform.selectedid.value;
          
          if(id == null || id.length == 0 || id == "" || id == "-1")
          {
            alert("<%= message.getMessageDesc("PLEASE_SELECT") %>");
            return;
          }  
            
          var flag = confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>");
          if(!flag)
            return;
        document.umcodesummaryform.actionname.value="delete";
        document.umcodesummaryform.target="_parent";
        isRunning = true;
        document.umcodesummaryform.submit();
    }
<%--[SCRIPT]    [SCRIPT]--%>
</script>

</head>
<body>
<form name="umcodesummaryform" method="post" action="../Dispatcher"  target="_parent">
    <input type="hidden" name="pagename" value="umcodesummary">
    <input type="hidden" name="actionname">
    <%--input type="hidden" name="languagecode" value="<%= strLanguageCode %>"--%>
<%@ include file="/inc/PageLocation.inc" %>

<table width="100%" cellspacing="0" border="0" cellpadding="0">
  <tr> 
    <td> 
      <table width="100%" border="0" cellspacing="0">
  <tr> 
    <td class="summary_top" colspan="2" ></td>
  </tr>
  
  <%@ include file="/inc/SummarySearch.inc" %>
  
</table>
<table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
        <form>
          <tr class="deepblue-left" > 
            <td width="22" class="title_center">&nbsp;</td>
            <td class="title_center" width="65"><a href="javascript:page_summary('orderby','umcode');"><%=label.getLabelName("L_Code")%></a></td>
            <td width="50" class="title_center"><a href="javascript:page_summary('orderby','umname');"><%=label.getLabelName("L_Name")%></a></td>
            <td class="title_center"><a href="javascript:page_summary('orderby','umdesc');"><%=label.getLabelName("L_Description")%></a></td>
            <td class="title_center" width="60"><a href="javascript:page_summary('orderby','umtype');"><%=label.getLabelName("L_Type")%></a></td>
            <td class="title_center" width="60"><a href="javascript:page_summary('orderby','factor');"><%=label.getLabelName("L_Factor")%></a></td>
            <td class="title_center" width="100"><a href="javascript:page_summary('orderby','isbase');"><%=label.getLabelName("L_IsBasic")%></a></td>
          </tr>
          <%
            cat.info("Start loop");
            Vector umcodesummary=(Vector)pageContext.getAttribute("umcodesummary"); 
            if(umcodesummary==null)
            {
                umcodesummary=new Vector();
            }
            int i=0;
            String strClassType="";
            
            cat.debug("umcodesummary is :"+umcodesummary);
            
            Integer nDefaultInvoiceId = new Integer(-1);
            String strChecked = "";
            boolean bHasChecked = false;
            
            String strDefaultCode="";
            
            OvalLabel labelEN = new OvalLabel("en",strModuleName); 
            OvalLabel labelCN = new OvalLabel("cn",strModuleName); 
          %>
          <logic:iterate id="umcodesummaryitem" collection="<%= umcodesummary %>">
          <%
            if(i%2 == 1)
            {
              strClassType = "td-listrom";
            }else{                    
              strClassType = "none";
            }
            if(!bHasChecked)
            {
              nDefaultInvoiceId = (Integer)((HashMap)pageContext.getAttribute("umcodesummaryitem")).get("umid");
              strDefaultCode= (String)((HashMap)pageContext.getAttribute("umcodesummaryitem")).get("umcode");
              bHasChecked = true;
              strChecked = "Checked";
            }
            else
            {
              strChecked = "";
            }
            i++;
            String strUmType=(String)((HashMap)pageContext.getAttribute("umcodesummaryitem")).get("umtype");
            if(strUmType==null)
            {
                strUmType="";
            }
            if(strUmType.equalsIgnoreCase(labelCN.getLabelName("L_Length"))||strUmType.equalsIgnoreCase(labelEN.getLabelName("L_Length")))
                strUmType=label.getLabelName("L_Length",false);
            else  if(strUmType.equalsIgnoreCase(labelCN.getLabelName("L_Weight"))||strUmType.equalsIgnoreCase(labelEN.getLabelName("L_Weight")))
                strUmType=label.getLabelName("L_Weight",false);
            else  if(strUmType.equalsIgnoreCase(labelCN.getLabelName("L_Volume"))||strUmType.equalsIgnoreCase(labelEN.getLabelName("L_Volume")))
                strUmType=label.getLabelName("L_Volume",false);
            
            
          %>
          <tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull(strClassType)%>'"  onClick="javascript:page_radiotrue('umid<%=JspHelper.filterNull(i)%>','<oval:write name="umcodesummaryitem" property="umcode" />')" class="<%=JspHelper.filterNull(strClassType)%>"> 
            <td> 
              <input id="umid<%=JspHelper.filterNull(i)%>" type="radio" name="_umid" value='<oval:write name="umcodesummaryitem" property="umid" />' class="normalradio" <%=JspHelper.filterNull(strChecked)%> >
            </td>
            <td>&nbsp;<oval:write name="umcodesummaryitem" property="umcode" /></td>
            <td>&nbsp;<oval:write name="umcodesummaryitem" property="umname" /></td>
            <td>&nbsp;<oval:write name="umcodesummaryitem" property="umdesc" /></td>
            <td>&nbsp;<%=JspHelper.filterNull(strUmType)%></td>
            <td>&nbsp;<oval:write  isView="true" schemaName="ovumcode" name="umcodesummaryitem" property="factor" /></td>
            <td>&nbsp;<oval:write name="umcodesummaryitem" property="isbase" /></td>
          </tr>
          </logic:iterate>
          <%cat.info("end loop");%>
          <input type=hidden name="selectedid" value='<%=JspHelper.filterNull(nDefaultInvoiceId)%>'>
          <input type=hidden name="selectedcode" value='<%=JspHelper.filterNull(strDefaultCode)%>'>
          <input type=hidden name="umcode" value='<%=JspHelper.filterNull(strDefaultCode)%>'>
          
          <tr> 
            <td colspan="7"> 
              <table width="100%" cellspacing="0" border="0">
                <%@ include file="/inc/SummaryAction.inc" %>  
              </table>
            </td>
          </tr>
        
      </table>
      <table width="100%" cellspacing="0" cellpadding="0">
        <tr> 
          <td class="summary_top"></td>
        </tr>
        <tr> 
          <td class="td_center">
          <a onclick="parent.down.location.href='UmCodeEdit.jsp?<%= OvalTools.randomURL() %>&isnew=y';"><custom:button type="1" label="L_New" imgsrc="new.gif" border="0" style="width:60"/></a>
          <a onclick="page_edit();"><custom:button type="1" label="L_Edit" imgsrc="edit.gif" border="0" style="width:60"/></a>
          <a onclick="page_delete();"><custom:button type="1" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60"/></a></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</form>
</body>
</html>


